package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import java.io.IOException;
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;


@SpringBootApplication
public class FunctionalWebApplication2 {

    public static void main(String[] args) throws IOException, InterruptedException {
        SpringApplication.run(FunctionalWebApplication2.class);
    }


    @Bean
    public RouterFunction<ServerResponse> monoRouterFunction(EchoHandler echoHandler) {
        return route(GET("/echo"), echoHandler::echo);
    }

    @Bean
    public RouterFunction<ServerResponse> monoRouterFunction2(EchoHandler echoHandler) {
        return route(POST("/echo2"), echoHandler::echo);
    }
}
